# include # include # define GRAN 100000000 # define SHIRINA 10000 # define VISOTA 10000 char red[SHIRINA*VISOTA*3];//3072000=1280*800*3 char stroka[54]; struct point { char red; char green; char blue; }; struct point_kor { int x; int y; }; point massiv[SHIRINA][VISOTA]; int abs(int f) { if (f<0) f=-f; return f; } double max(double a, double b) { if(a>b) { return a; } else return b; } double min(double a, double b) { if(a>b) { return b; } else return a; } //------------------------------------------------------------------------------------------------------------------------------------------- void otrezok(point mas[SHIRINA][VISOTA],int x1,int y1,int x2,int y2,point color) { //--------------------точки для уравнения прямой------------------------------------------------------------------------ double x1q,y1q,x2q,y2q; if(x1>x2) { x1q=x1+0.5; x2q=x2-0.5; } else if(x2>x1) { x1q=x1-0.5; x2q=x2+0.5; } else { x1q=x1-0.5; x2q=x2+0.5; } if(y1>y2) { y1q=y1+0.5; y2q=y2-0.5; } else if(y2>y1) { y1q=y1-0.5; y2q=y2+0.5; } else { y1q=y1-0.5; y2q=y2+0.5; } //---------------Проверка точек на принадлежность----------------------------------------------- double a,b,c=0; int aa,bb; //for(bb=0;bb0 ) { c++; } else if( a*(y2q-y1q)+b*(x1q-x2q)+x1q*(y1q-y2q)+y1q*(x2q-x1q)<0 ) c--; a=aa+0.5; b=bb+0.5; if( a*(y2q-y1q)+b*(x1q-x2q)+x1q*(y1q-y2q)+y1q*(x2q-x1q)>0 ) { c++; } else if( a*(y2q-y1q)+b*(x1q-x2q)+x1q*(y1q-y2q)+y1q*(x2q-x1q)<0 ) c--; a=aa+0.5; b=bb-0.5; if( a*(y2q-y1q)+b*(x1q-x2q)+x1q*(y1q-y2q)+y1q*(x2q-x1q)>0 ) { c++; } else if( a*(y2q-y1q)+b*(x1q-x2q)+x1q*(y1q-y2q)+y1q*(x2q-x1q)<0 ) c--; a=aa-0.5; b=bb+0.5; if( a*(y2q-y1q)+b*(x1q-x2q)+x1q*(y1q-y2q)+y1q*(x2q-x1q)>0 ) { c++; } else if( a*(y2q-y1q)+b*(x1q-x2q)+x1q*(y1q-y2q)+y1q*(x2q-x1q)<0 ) c--; if(abs(c)!=4) { //printf("hello aa=%d bb=%d\n",aa,bb); mas[aa][bb].red=color.red; mas[aa][bb].green=color.green; mas[aa][bb].blue=color.blue; } if(abs(c)==3) { //printf("hello aa=%d bb=%d\n",aa,bb); mas[aa][bb].red=color.red+80; mas[aa][bb].green=color.green+80; mas[aa][bb].blue=color.blue+80; } //printf("abs(c)=%d\n",abs(c)); } } } //-------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------- int simple[GRAN]; //-------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------- int main() { //--------------Заполнение массива--------------------------------------------------------------------------- int i,j,r,r1,r2,k,u; //----Заполняем всё белым цветом----------------------------------------------------------------------- for(r2=0;r20) { b--; i++; if(simple[i]!=0) { massiv[a][b].red=255; massiv[a][b].green=255; massiv[a][b].blue=255; } n--; } if(shag_resim==0) { shag_resim=1; } else { shag++; shag_resim=0; } side++; continue; } if(side==2) { n=shag; while(n>0) { a++; i++; if(simple[i]!=0) { massiv[a][b].red=255; massiv[a][b].green=255; massiv[a][b].blue=255; } n--; } if(shag_resim==0) { shag_resim=1; } else { shag++; shag_resim=0; } side++; continue; } if(side==3) { n=shag; while(n>0) { b++; i++; if(simple[i]!=0) { massiv[a][b].red=255; massiv[a][b].green=255; massiv[a][b].blue=255; } n--; } if(shag_resim==0) { shag_resim=1; } else { shag++; shag_resim=0; } side++; continue; } if(side==4) { n=shag; while(n>0) { a--; i++; if(simple[i]!=0) { massiv[a][b].red=255; massiv[a][b].green=255; massiv[a][b].blue=255; } n--; } if(shag_resim==0) { shag_resim=1; } else { shag++; shag_resim=0; } side=1; continue; } } //-----Слив массива точек в массив red----------------------------------------------------------------------- r=0; for(r2=0;r2